﻿
Paydate = {
    PaydateUpdatePopUpId: '',
    CurrentRow: null,
    OnAddPaydateClick: function () {
        $('#btnAddPaydate').live("click", function (e) {
            e.preventDefault();            
            var id = $(this).attr("id");
            Paydate.PaydateUpdatePopUpId = id;

            PopUpDialog.UrlDialog("Payroll Date", 420, 350, true, "../../PopupBoxes/PayrollDateDialogbox.aspx?id=0", id);

        });
    },
    OnDeletePaydateClick: function () {
        $('table#PayrollDatetbl .btnDelete').live("click", function (e) {
            e.preventDefault();
            if (confirm('Are you sure you want to delete item?')) {
                var id = $(this).attr("data-id");
                var json = JSON.stringify({ Id: id });
                SSS.CurrentRow = $(this).closest("tr");
                $.ajax({
                    type: "POST",
                    url: "../Webservices/UtilitiesWebsService.asmx/DeleteSSS",
                    data: json,
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (data) {
                        var response = eval('(' + data.d + ')');
                        if (response.Success) {
                            SSS.CurrentRow.remove();                            
                        }
                    }
                });

            }
        });
    },
    SetRowData: function (Obj) {
        if (Obj.IsAdded) {
            location.reload(true);
        }
        var id = Obj.SSSItem.Id;
        var startRange = Obj.SSSItem.StartRange;
        var endRange = Obj.SSSItem.EndRange;
        var er = Obj.SSSItem.Er;
        var ee = Obj.SSSItem.Ee;
        var base = Obj.SSSItem.Base;
        var total = Obj.SSSItem.Total;

        SSS.CurrentRow.find("td").eq(0).html(id);
        SSS.CurrentRow.find("td").eq(1).html(startRange);
        SSS.CurrentRow.find("td").eq(2).html(endRange);
        SSS.CurrentRow.find("td").eq(3).html(er);
        SSS.CurrentRow.find("td").eq(4).html(ee)
        SSS.CurrentRow.find("td").eq(5).html(base);
        SSS.CurrentRow.find("td").eq(6).html(total);
    }
}

$(document).ready(function () {
    Paydate.OnAddPaydateClick();
});